<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>不用柯里化的实现</title>
    <style>

    </style>
</head>
<body>
<!--准备好一个容器-->
<div id="root"></div>

<!--引入React核心库-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react.development.js"></script>
<!--引入React-Dom，用于支持React操作Dom-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react-dom.development.js"></script>
<!--引入babel，用于将jsx转为js-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/babel.min.js"></script>

<script type="text/babel">

    //创建组件
    class Login extends React.Component {

        //初始化状态
        state = {
            userName: '',
            passWord: ''
        }

        saveFormData = (dataType, value) => {
            this.setState({
                [dataType]: value
            })
        }

        handleSubmit = (event) => {
            event.preventDefault()//阻止表单提交
            const {userName,passWord} = this.state
            alert(`你输入的用户名是${userName}，你输入的密码是${passWord}`)
        }

        render() {
            return (
                <form onSubmit={this.handleSubmit}>
                    用户名：<input onChange={(event)=>{this.saveFormData('userName',event.target.value)}} type="text" name="userName"/>
                    密码：<input onChange={(event)=>{this.saveFormData('passWord',event.target.value)}} type="password" name="passWord"/>
                    <button>登陆</button>
                </form>
            )
        }
    }

    //渲染组件到页面
    ReactDOM.render(<Login/>, document.getElementById('root'));

</script>

</body>
</html>
